import router from './router'
import store from './store'
import { Message } from 'element-ui'

router.beforeEach((to, from, next) => {
  const isLogin = localStorage.getItem('token')
  if (isLogin || to.path === '/share' || to.path === '/share/map') {
    next()
  } else {
    if (to.path === '/form/map' || to.path === '/point/map' || to.path === '/share' || to.path === '/share/map') {
      next()
    } else {
      next('/form/map')
    }
    Message.error('请登录')
  }
  store.commit('changeFile', [])
})
